﻿using MDT.LifeSewagePlatform.Conmmon;
using MDT.LifeSewagePlatform.InterfaceService;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace MDT.LifeSewagePlatform.ServiceInstance.Controllers
{
    [Route("api/system/env")]
    [ApiController]
    [Authorize]
    public class SystemEnvController : BaseController
    {
        #region prop and ctor
        [Autowired]
        public ISystemEnvService systemEnvService { get; set; }

        public SystemEnvController()
        {

        }
        #endregion

        #region method service
        /// <summary>
        /// 设置环境变量
        /// </summary>
        /// <param name="env"></param>
        /// <returns></returns>
        [HttpPut("{env}")]
        [CustomActionFilter(Role = RoleType.Admin)]
        public async Task<BaseMessage> UpSystemEnv(int env)
        {
            return await systemEnvService.SetSystemEnv(env);
        }
        /// <summary>
        /// 获取可以设置的下拉列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("current")]
        [CustomActionFilter(Role = RoleType.Child)]
        public  BaseMessage GetSystemEnv()
        {
            return systemEnvService.GetSystemEnv();
        }
        /// <summary>
        /// 获取当前值，根据月统计还是根据季度统计
        /// </summary>
        /// <returns></returns>
        
        [HttpGet()]
        [CustomActionFilter(Role = RoleType.Admin)]
        public BaseMessage GetSystemEnvs()
        {
            return systemEnvService.GetEnvs();
        }
        #endregion
    }
}
